﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
/// Summary description for Connection
/// </summary>
public class Connection
{
    SqlConnection con;
	public Connection()
	{
        try
        {
            string str = ConfigurationManager.ConnectionStrings[1].ToString();
            con = new SqlConnection(str);
        }
        catch (Exception ex)
        {
            
            throw new Exception("Khong ket noi dc " + ex.Message);
        }
	}
    public SqlConnection getCon()
    {
        try
        {
            return con;
        }
        catch (Exception ex)
        {
            
            throw new Exception("khong get dc connection" + ex.Message);
        }
    }
    public void openCon()
    {
        try
        {
            con.Open();
        }
        catch (Exception ex)
        {
            
            throw new Exception("khong mo dc ket noi keke" + ex.Message);
        }
    }
    public void closeCon()
    {
        try
        {
            con.Close();
        }
        catch (Exception ex)
        {
            
            throw new Exception("khong dong dc ket noi" + ex.Message);
        }
    }
}